<?php

/**
 * Description of Controller
 *
 * @author Lisette, Monica
 * @date: 2012-06-26 20:20
 * @modifications: 2012-06-27 00:00 Lisette (Following: http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/)
 */
class BaseController {

    protected $_model;
    protected $_controller;
    protected $_action;
    protected $_template;

    /**
     * Constructor
     * (DocumentDAO, DocumentController, create);
     * @param type $model
     * @param type $controller
     * @param type $action 
     */
    function __construct($model, $controller, $action) {
        $this->_controller = $controller;
        $this->_action = $action;
        $this->_model = $model;
        
        if(isset($model)){
            $method = "get".$model;           
            $this->_model =& DAOFactory::$method();           
        }
        
        $this->_template =& new Template($controller, $action);
    }

    /**
     * set the view (template)
     * @param type $name
     * @param type $value 
     */
    function set($name, $value) {
        $this->_template->set($name, $value);
    }

    /**
     * For displaying the view 
     */
    function __destruct() {
        $this->_template->render();
    }

}